﻿using Microsoft.Extensions.Configuration;
using System.IO;

namespace jianvgroup.com.Common
{
    public class ConfigHelper
    {
        private static IConfigurationRoot config;
        ~ConfigHelper() { }
        public static string GetConfigSetting(string name)
        {
            config = Builder();
            return config.GetSection("AppSettings:" + name).Value;
        }

        public static string GetConfigSetting(string key, string value)
        {
            config = Builder();
            return config.GetSection(key + ":" + value).Value;
        }

        public static IConfigurationRoot Builder()
        {
            var builder = new ConfigurationBuilder()
                .SetBasePath(Directory.GetCurrentDirectory())
                .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

            return builder.Build();
        }
    }
}
